﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Web;
using VitCode.Castle.DataAccess;

namespace VitCode.Castle.Entities
{
    public abstract class BaseEntity
    {
        public static string ID = "Id";
        public virtual StringCollection GetNotCompareHisProNames()
        {
            return new StringCollection() { "Id", "LastEditDate", "LastEditUserId", "ImportNum",  "CreateUserId" };
        }

        protected Guid m_Id;
        /// <summary>
        /// 唯一标识
        /// </summary>
        public virtual Guid Id
        {
            get { return m_Id; }
            set { m_Id = value; }
        }

        protected string m_Memo;
        /// <summary>
        /// 备注
        /// </summary>
        public virtual string Memo
        {
            get { return m_Memo; }
            set { m_Memo = value; }
        }

        protected Guid m_CreateUserId;
        /// <summary>
        /// 记录创建的系统用户ID
        /// </summary>
        public virtual Guid CreateUserId
        {
            get { return m_CreateUserId; }
            set { m_CreateUserId = value; }
        }

        protected Guid m_LastEditUserId;
        /// <summary>
        /// 最后一次记录修改的系统用户Id
        /// </summary>
        public virtual Guid LastEditUserId
        {
            get { return m_LastEditUserId; }
            set { m_LastEditUserId = value; }
        }

        protected DateTime m_LastEditDate = DateTime.Now;
        /// <summary>
        /// 最后一次记录修改的时间
        /// </summary>
        public virtual DateTime LastEditDate
        {
            get { return m_LastEditDate; }
            set{ m_LastEditDate = value;}
        }

        protected string m_ImportNum;
        /// <summary>
        /// 记录的导入批次号(在新增记录时生成,同一批次导入记录,产生同一个批次号)
        /// </summary>
        public virtual string ImportNum
        {
            get { return m_ImportNum; }
            set { m_ImportNum = value; }
        }

        protected bool m_IsLogicDelete;
        /// <summary>
        /// 逻辑删除的标记
        /// </summary>
        public virtual bool IsLogicDelete
        {
            get { return m_IsLogicDelete; }
            set{ m_IsLogicDelete = value;}
        }

        protected string m_KeyWord;
        /// <summary>
        /// 关键字(以","分格)
        /// </summary>
        public virtual string KeyWord
        {
            get { return m_KeyWord; }
            set { m_KeyWord = value; }
        }

        public static string GetImportNum()
        {
            return DateTime.Now.ToString("yyyyMMddhhmmssffff");
        }

        

        public virtual void SetSysExPro()
        {
            if (m_Id == Guid.Empty)
            {
                m_ImportNum = GetImportNum();
                m_CreateUserId = GenericContext.CurrUserId;
            }
            m_LastEditDate = DateTime.Now;
            m_LastEditUserId = GenericContext.CurrUserId;

        }

        
    }
}
